package cn.neusoft.staticproxy;

public class EmpServiceProxy implements EmpService{
	EmpService target;

	public EmpServiceProxy(EmpService target) {
		this.target = target;
	}

	@Override
	public void add() {
		System.out.println("开启事务");
		try{
			target.add();
			System.out.println("提交事务");
		}catch(Exception e) {
			System.out.println("回滚事务");
		} finally {
			System.out.println("关闭事务");
		}
	}

	@Override
	public void update() {
		System.out.println("开启事务");
		try{
			target.add();
			System.out.println("提交事务");
		}catch(Exception e) {
			System.out.println("回滚事务");
		} finally {
			System.out.println("关闭事务");
		}
	}
}
